package mutil.thread;

/**
 * Created by luoqifei on 17-7-12.
 */
public class SleepTest {
    public static void main(String[] args) {
        Thread thread1 = new Thread(new Runnable() {
            public void run() {
                System.out.println("hello,i am the max priory Thread");
                System.out.println("i start to sleep 4 s");
//                try {
//                    Thread.sleep(4000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
                long now = System.currentTimeMillis();
                long end = now+6000l;
                while (System.currentTimeMillis() < end){
                    //System.out.println(System.currentTimeMillis());
                }
                System.out.println("i have sleep 4s");
            }
        });
        thread1.setPriority(Thread.MAX_PRIORITY);

        Thread thread2 = new Thread(new Runnable() {
            public void run() {
                System.out.println("hello,i am the min priory Thread");
                System.out.println("i start to sleep 1 s");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("i have sleep 1s");
            }
        });
        thread2.setPriority(Thread.MIN_PRIORITY);
        thread1.start();

        thread2.start();
    }

}
